import os
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template
from google.appengine.ext.webapp.util import run_wsgi_app

class MainPage(webapp.RequestHandler):
  def get(self):
    user = users.get_current_user()
    if user:
      self.response.out.write('Welcome ' + user.nickname() +' <a href="'+users.create_login_url(self.request.uri)+'">Logout</a>')
    else:
      self.response.out.write('<a href="'+users.create_login_url(self.request.uri)+'">Go identify your self</a>')
    template_values = {
      'title': "Registration",
      'wp_url_xmlrpc': "",
      'wp_username': "",
      'wp_password': ""
    }
    path = os.path.join(os.path.dirname(__file__), 'register.tpl')
    self.response.out.write(template.render(path, template_values))

application = webapp.WSGIApplication(
			[('/register/', MainPage)],
			debug=True)

def main():
  run_wsgi_app(application)

if __name__ == "__main__":
  main()
